
import java.util.*;
public class Catalog implements Iterable<Product>{
    private ArrayList<Product> products=new ArrayList<Product>();
    public Catalog(){
    };
    public void addProduct(Product product){
        products.add(product);
    }
    public Iterator<Product> iterator(){
       Iterator<Product> a=products.iterator();
       return a;
    }
    public Product getProduct(String code){
        for(Iterator<Product>a=this.products.iterator();a.hasNext();){
            Product product=a.next();
            if(product.getCode().equals(code)){
                return product;
            }
        }return null;

    }
    public int getNumberOfProducts(){
        return products.size();
    }

}